#include "systick.h"

//max=1864ms
void SysTick_Delay_Nms(uint32_t Nms)
{
  SysTick->CTRL=0;
  SysTick->LOAD=Nms*9000;
  SysTick->CTRL=SysTick_CLK_REF|SysTick_INT|SysTick_ENABLE;
  //wait flag==1
  while(!(SysTick->CTRL & (1<<16)));
  SysTick->CTRL=0;
  SysTick->VAL=0;
}

void SysTick_Delay_Nus(uint32_t Nus)
{
  SysTick->CTRL=0;
  SysTick->LOAD=Nus*72;
  SysTick->CTRL=0x05;
  //wait flag==1
  while(!(SysTick->CTRL & (1<<16)));
  SysTick->CTRL=0;
  SysTick->VAL=0;
}